<?php

/**
 * Compania form base class.
 *
 * @method Compania getObject() Returns the current form's model object
 *
 * @package    aeropostal
 * @subpackage form
 * @author     Your name here
 */
abstract class BaseCompaniaForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'rif'         => new sfWidgetFormInputText(),
      'codSistF'    => new sfWidgetFormInputText(),
      'nombre'      => new sfWidgetFormInputText(),
      'descripcion' => new sfWidgetFormInputText(),
      'tlf'         => new sfWidgetFormInputText(),
      'direccion'   => new sfWidgetFormInputText(),
      'uMedida'     => new sfWidgetFormPropelChoice(array('model' => 'Unidmedida', 'add_empty' => true)),
      'moneda'      => new sfWidgetFormPropelChoice(array('model' => 'Moneda', 'add_empty' => true)),
      'contacto'    => new sfWidgetFormInputText(),
      'tlfContacto' => new sfWidgetFormInputText(),
      'logotipo'    => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorChoice(array('choices' => array($this->getObject()->getId()), 'empty_value' => $this->getObject()->getId(), 'required' => false)),
      'rif'         => new sfValidatorString(array('max_length' => 255)),
      'codSistF'    => new sfValidatorInteger(array('min' => -2147483648, 'max' => 2147483647)),
      'nombre'      => new sfValidatorString(array('max_length' => 255)),
      'descripcion' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'tlf'         => new sfValidatorString(array('max_length' => 255)),
      'direccion'   => new sfValidatorString(array('max_length' => 255)),
      'uMedida'     => new sfValidatorPropelChoice(array('model' => 'Unidmedida', 'column' => 'simbolo', 'required' => false)),
      'moneda'      => new sfValidatorPropelChoice(array('model' => 'Moneda', 'column' => 'id', 'required' => false)),
      'contacto'    => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'tlfContacto' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'logotipo'    => new sfValidatorString(array('max_length' => 255, 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorPropelUnique(array('model' => 'Compania', 'column' => array('rif'))),
        new sfValidatorPropelUnique(array('model' => 'Compania', 'column' => array('nombre'))),
      ))
    );

    $this->widgetSchema->setNameFormat('compania[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Compania';
  }


}
